<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Cool Cloud</title>

    <!-- Google Font: Source Sans Pro -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.24/datatables.min.css"/>
    <link rel="stylesheet" type="text/css"
          href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css"/>
    <!-- Theme style -->
    <link rel="stylesheet" href="dist/css/adminlte.min.css">
    <!--  分页-->
    <link rel="stylesheet" href="dist/css/zxf_page.css">
    <link rel="stylesheet" href="dist/js/xcConfirm/css/xcConfirm.css">
    <style>
        .tipmsg {
            background-color: #f39c12;
            position: absolute;
            z-index: 100;
            top: 30px;
            right: 3%;
            padding: 5px 5px 5px 5px;
            border-radius: 15px;
            border: 2px solid #ddd;
            box-shadow: 0 15px 15px -5px rgba(0, 0, 0, 0.2);
            color: white;
        }
    </style>
</head>
<body class="hold-transition sidebar-mini">
<!-- wrapper -->
<div class="wrapper">
    <!-- Navbar -->
    <div th:replace="common/header :: header"></div>

    <!-- Main Sidebar Container -->
    <div th:replace="common/menu :: sidebar"></div>

    <!-- Content Wrapper. Contains page content -->
    <div th:replace="content/userContent :: usercontent"></div>

    <!-- /Footer -->
    <div th:replace="common/footer :: footer"></div>

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark"></aside>
</div>


<!--编辑个人信息-->
<div th:replace="common/editInforModel :: editinfo"></div>
<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="plugins/bootstrap/js/bootstrap.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- DataTables -->
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.24/datatables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
<!--分页-->
<script type="text/javascript" src="dist/js/zxf_page.js"></script>
<!--邀请注册-->
<script src="dist/js/invite.js"></script>
<!--xcConfirm-->
<script src="dist/js/xcConfirm/js/xcConfirm.js"></script>
<!--搜索-->
<script src="dist/js/search.js"></script>
<!-- Page specific script -->
<script>

    function editMyInfo() {
        $(".userName").val("[[${session.loginUser.userName}]]");
        $(".editinfo").click();
    }

    function submit() {
        let userName = $(".userName").val();
        let IwtNewPsd = $(".IwtNewPsd").val();
        let IwtOralPsd = $(".IwtOralPsd").val();
        let id = [[${session.loginUser.userId}]];
        console.log(userName, id, IwtNewPsd, IwtOralPsd)
        if (userName == '') {
            alert("用户名不能为空！");
            return;
        }
        if ((IwtNewPsd == '' && IwtOralPsd != '') || (IwtNewPsd != '' && IwtOralPsd == '')) {
            alert("需要修改密码,原密码与新密码均不能为空！");
            return;
        }
        $.ajax({
            url: "UpdateInfo",
            type: "POST",
            data: {
                "id": id,
                "username": userName,
                "IwtNewPsd": IwtNewPsd,
                "IwtOralPsd": IwtOralPsd
            },
            success: function (date) {
                if (date.status == "psdwrong") {
                    alert("原密码错误！")
                } else if (date.status == "success" && IwtNewPsd != '') {
                    $("#logout").click();
                } else if (date.status == "success" && IwtNewPsd == '') {
                    $(".tipmsg").html($('<span  style="margin-right: 25px">  用户名修改成功！</span><i class="fas fa-times" onclick="closeTip()"></i>'));
                    $(".tipmsg").show();
                    $('.close').click();
                    setInterval("location.reload( )", 1000);
                }
            }
        })
    }


    //翻页
    $(".zxf_pagediv").createPage({
        pageNum: $('#pageNum').html(),
        current: $('#current').html(),
        backfun: function (e) {
            var location = window.location.href;
            let strings = location.split("coolcloud");
            console.log(strings[0]);
            window.location.href = strings[0] + "coolcloud/manage-user?cur=" + e['current'];
        }
    });

    function updateStore(id) {
        var pre = '#permission' + id;
        var size = '#size' + id;
        if ($(size).val() < 1024) {
            alert("仓库容量最小为1024MB！");
            return;
        }
        $.ajax({
            type: "GET",
            url: "updateStoreInfo",
            data: {
                "uId": id,
                "pre": $(pre).val(),
                "size": $(size).val()
            },
            success: function (data) {
                if (data == "200") {
                    alert("修改成功！");
                }
            },
            error: function (e) {
                console.log(e.responseText);
            }
        });
    }
</script>
</body>
</html>
